﻿using JESAI.Redis.Abstracts;
using JESAI.Redis.Abstracts.Commands;
using JESAI.Redis.Abstracts.RedisClients;
using JESAI.Redis.Builders;
using JESAI.Redis.Datas;
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace JESAI.Redis.RedisClients.Adapter
{
    public class SimpleRedisClient : IRedisClient
    {
        /// <summary>
        /// tcp 客户端
        /// </summary>
        protected TcpClient TcpClient { get; set; }

        /// <summary>
        /// 连接信息
        /// </summary>
        public IConnectionBuilder ConnectionBuilder { get; }

        /// <summary>
        /// 连接Id
        /// </summary>
        public string Key { get; private set; }

        /// <summary>
        /// 主机信息
        /// </summary>
        public string Host { get; protected set; }

        /// <summary>
        /// 串口
        /// </summary>
        public int Port { get; protected set; }

        /// <summary>
        /// 客户端ID
        /// </summary>
        public string ClientId { get; protected set; }

        /// <summary>
        /// 是否授权
        /// </summary>
        protected bool IsAuth { get; set; }

        /// <summary>
        /// 最后一次收包时间
        /// </summary>
        public long LastReceivePackTime { get; private set; }

        /// <summary>
        /// 数据库索引
        /// </summary>
        public int CurrentDBIndex { get; private set; }

        /// <summary>
        /// 目标数据库索引
        /// </summary>
        public int TargetDBIndex { get; private set; }

        /// <summary>
        /// 是否已经关闭
        /// </summary>
        private bool _isClose;
        public bool IsClose => _isClose ? _isClose : !TcpClient.Connected;

        /// <summary>
        /// 最后使用时间
        /// </summary>
        public DateTime LastUseTime { get; set; }

        public string RedisHost => throw new NotImplementedException();

        public void Dispose()
        {

        }

        public Task InitClientAsync()
        {
            throw new NotImplementedException();
        }

        public Task<T> ExecuteAsync<T>(IRedisCommandArg commandArg)
        {
            throw new NotImplementedException();
        }

        public Task<RedisData> ExecuteSampleAsync(IRedisCommandArg commandArg)
        {
            throw new NotImplementedException();
        }

        public Task ExecuteNoResultAsync(IRedisCommandArg commandArg)
        {
            throw new NotImplementedException();
        }

        public Task<object> ReadMessageAsync()
        {
            throw new NotImplementedException();
        }

        public Task<RedisData> InvokeAsync(IRedisCommandArg commandArg)
        {
            throw new NotImplementedException();
        }

        public Task<bool> PingAsync()
        {
            throw new NotImplementedException();
        }

        public Task<bool> ChangeDb(int dbIndex)
        {
            throw new NotImplementedException();
        }

        public Task<bool> AuthAsync(string userName, string password)
        {
            throw new NotImplementedException();
        }

        public Task<bool> QuitAsync()
        {
            throw new NotImplementedException();
        }

        public Task ReconnectAsync(CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public Task ReconnectSocketAsync(CancellationToken cancellationToken = default)
        {
            throw new NotImplementedException();
        }

        public void Close()
        {
            throw new NotImplementedException();
        }
    }
}
